const $Toast = {
  none: (str, time = 3000) => {
    return new Promise((resolve, reject) => {
      uni.showToast({
        title: str,
        icon: "none",
        duration: time,
        mask: true,
        success: () => {
          setTimeout(() => {
            resolve()
          }, time)
        }
      })
    })
  },
  success: (str, time = 3000) => {
    return new Promise((resolve, reject) => {
      uni.showToast({
        title: str,
        icon: "success",
        duration: time,
        mask: true,
        success: () => {
          setTimeout(() => {
            resolve()
          }, time)
        }
      })
    })
  },
  loading: (str) => {
    return new Promise((resolve, reject) => {
      uni.showLoading({
        title: str,
        icon: "loading",
        mask: true,
        success: () => {
          resolve();
        }
      })
    })
  },
  error: (str, time = 3000) => {
    return new Promise((resolve, reject) => {
      uni.showToast({
        title: str,
        icon: "error",
        duration: time,
        mask: true,
        success: () => {
          setTimeout(() => {
            resolve()
          }, time)
        }
      })
    })
  },
}

export {
  $Toast
}
